import OpenGL.GL as gl
import numpy as np

class RenderBufferObject:
    def __init__(self, internal_format: int, width: int, height: int) -> None:
        rbo = np.empty(1, gl.GLuint)
        gl.glCreateRenderbuffers(1, rbo)
        self.rbo_id = rbo[0]
        self.internal_format = internal_format
        self.resize(width, height)

    def resize(self, width, height)->None:
        self.width = width
        self.height = height
        gl.glNamedRenderbufferStorage(self.rbo_id, self.internal_format, 
                                      width, height)

    def delete(self) -> None:
        if gl.glIsRenderbuffer(self.rbo_id):
            gl.glDeleteRenderbuffers(1, self.rbo_id)

